<template>
    <el-button type="primary" plain @click="all">查询所有</el-button>
    <el-button type="primary" plain @click="nostart">未开始</el-button>
    <el-button type="success" plain @click="nofinish">进行中</el-button>
    <el-button type="warning" plain @click="finish">已完成</el-button>
  <el-table :data="detail.list" style="width: 100%">
    <el-table-column label="ID" prop="id" />
    <el-table-column label="计划标题" prop="name" />
    <el-table-column label="所属社区" prop="planCommunity" />
    <el-table-column label="开始时间" prop="startTime" />
    <el-table-column label="结束时间" prop="endTime" />
    <el-table-column label="状态" prop="status" />
    <el-table-column label="维护人员" prop="planManName" />
  </el-table>
  <el-pagination  v-if="this.detail.total > 5"
    v-model:currentPage="detail.pageNum"
    v-model:page-size="detail.pageSize"
    :total="detail.total"
    :page-sizes="[5, 10]"
    :small="small"
    :background="background"
    layout="total, sizes, prev, pager, next, jumper"
    @size-change="handleSizeChange"
    @current-change="handleCurrentChange"
  ></el-pagination>
</template>

<script>
export default {
  name: "planwork",
  data() {
    return {
      plan: {},
      detail: [
        {
          list: [],
          total: 0,
          pageNum: null,
          pageSize: null,
        },
      ],
      user: {},
      planModel: {}
    };
  },
  methods: {
    handleSizeChange(size) {
      this.detail.pageSize = size;
      this.mount();
    },
    handleCurrentChange(num) {
      this.pageNum = num;
      this.mount();
    },
    mount() {
      this.$axios({
        method: "post",
        url: "http://localhost:8080/nav/accendant/jobone",
        data:
          this.$qs.stringify(this.user) +
          "&" +
          this.$qs.stringify(this.planModel)+
          "&" +
          this.$qs.stringify({
            pageSize: this.detail.pageSize,
            pageNum: this.detail.pageNum,
          }),
      }).then((res) => {
        console.log(res.data);
        this.project2 = res.data;
        if (res.data.code == 1) {
          this.detail.list = res.data.data.list;
          this.detail.pageSize = res.data.data.pageSize;
          this.detail.pageNum = res.data.data.pageNum;
          this.detail.total = res.data.data.total;
        } else {
          console.log("error");
        }
      });
    },
    nostart(){
      this.planModel.status = "未开始";
      this.mount();
    },
    nofinish(){
      this.planModel.status = "进行中";
      this.mount();
    },
    finish(){
      this.planModel.status = "已完成";
      this.mount();
    },
    all(){
      this.planModel.status = "";
      this.mount();
    }
  },
  mounted() {
    this.user = this.$store.state.user;
    this.mount();
  },
};
</script>
